﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.ValentineUI {
    import flash.events.*;
    import Engine.Managers.*;
    import Events.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import Classes.sim.*;
    import Display.*;
    import flash.text.*;
    import org.aswing.event.*;
    import Display.aswingui.*;
    import Modules.stats.types.*;

    public class MakerPanel extends JPanel {

        public static const PREPARE:String = "prepare";

        public var m_data:Dictionary;
        protected var m_messages:Array;
        protected var m_currentMessage:int = 0;
        protected var m_cardHolder:JPanel;
        protected var m_newMessage:String;
        protected var m_picture:PicturePane;

        public function MakerPanel(_arg1:Dictionary, _arg2:LayoutManager=null){
            this.m_messages = new Array();
            super(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, 0, SoftBoxLayout.TOP));
            this.m_data = _arg1;
            this.init();
        }
        protected function init():void{
            var _local1:AssetPane = ASwingHelper.makeMultilineText(ZLoc.t("Dialogs", "ValUI_introstring"), 600, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.LEFT, 14, EmbeddedArt.darkBrownTextColor);
            var _local2:JPanel = this.createPicturePanel();
            var _local3:JPanel = ASwingHelper.centerElement(_local2);
            var _local4:JButton = new CustomButton(ZLoc.t("Dialogs", "ValUI_sendValentine"), null, "PinkButtonUI");
            _local4.addActionListener(this.sendValentine, 0, true);
            var _local5:JPanel = ASwingHelper.centerElement(_local4);
            this.appendAll(_local1, ASwingHelper.verticalStrut(-5), _local3, ASwingHelper.verticalStrut(-7), _local5);
            ASwingHelper.setEasyBorder(this, 5, 20);
        }
        protected function sendValentine(_arg1:AWEvent):void{
            ValentineManager.sendValentineCard(this.m_picture.leftID, this.m_picture.centerID, this.m_picture.rightID, this.m_newMessage);
            var _local2:String = ((((("" + this.m_picture.leftID) + "_") + this.m_picture.centerID) + "_") + this.m_picture.rightID);
            StatsManager.count(StatsCounterType.CARDMAKER, StatsKingdomType.VDAY_2011, StatsPhylumType.CARDMAKER, "send");
            StatsManager.count(StatsCounterType.CARDMAKER, StatsKingdomType.VDAY_2011, StatsPhylumType.CARDMAKER, "send_creative", "left", String(this.m_picture.leftID));
            StatsManager.count(StatsCounterType.CARDMAKER, StatsKingdomType.VDAY_2011, StatsPhylumType.CARDMAKER, "send_creative", "center", String(this.m_picture.centerID));
            StatsManager.count(StatsCounterType.CARDMAKER, StatsKingdomType.VDAY_2011, StatsPhylumType.CARDMAKER, "send_creative", "right", String(this.m_picture.rightID));
            StatsManager.count(StatsCounterType.CARDMAKER, StatsKingdomType.VDAY_2011, StatsPhylumType.CARDMAKER, "send_creative", "combo", _local2);
        }
        protected function createPicturePanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            this.m_picture = new PicturePane(this.m_data);
            ASwingHelper.setSizedBackground(_local1, this.m_picture, new Insets(10, 0, 15, 0));
            var _local2:JButton = new CustomButton(ZLoc.t("Dialogs", "ValUI_changeText"), null, "PurpleButtonUI");
            var _local3:JPanel = ASwingHelper.centerElement(_local2);
            this.m_cardHolder = ASwingHelper.makeFlowJPanel(FlowLayout.CENTER);
            this.m_cardHolder.setPreferredHeight(35);
            this.m_cardHolder.setMinimumHeight(35);
            this.m_cardHolder.setMaximumHeight(35);
            this.m_newMessage = ZLoc.t("Dialogs", "ValUI_message1");
            var _local4:AssetPane = ASwingHelper.makeMultilineCapsText(this.m_newMessage, 342, EmbeddedArt.TITLE_FONT, TextFormatAlign.CENTER, 14, EmbeddedArt.whiteTextColor);
            this.m_cardHolder.append(_local4);
            var _local5:JPanel = ASwingHelper.makeFlowJPanel(FlowLayout.CENTER, 50);
            var _local6:JButton = new CustomButton(ZLoc.t("Dialogs", "ValUI_change"), null, "PurpleButtonUI");
            var _local7:JButton = new CustomButton(ZLoc.t("Dialogs", "ValUI_change"), null, "PurpleButtonUI");
            var _local8:JButton = new CustomButton(ZLoc.t("Dialogs", "ValUI_change"), null, "PurpleButtonUI");
            _local2.addActionListener(this.launchChangeText, 0, true);
            _local6.addActionListener(this.m_picture.swapSender, 0, true);
            _local7.addActionListener(this.m_picture.swapObject, 0, true);
            _local8.addActionListener(this.m_picture.swapRecipient, 0, true);
            _local5.appendAll(_local6, _local7, _local8);
            _local1.appendAll(ASwingHelper.verticalStrut(25), this.m_cardHolder, _local3, ASwingHelper.verticalStrut(200), _local5);
            return (_local1);
        }
        protected function launchChangeText(_arg1:AWEvent):void{
            var _local2:InputTextDialogNormal = new InputTextDialogNormal(ZLoc.t("Dialogs", "ValUI_ChangeText"), "ValUI_Change", "", this.m_newMessage, 50, 0, this.changeText, true, null, true);
            _local2.textField.addEventListener(Event.CHANGE, this.onNameDialogChange);
            UI.displayPopup(_local2);
        }
        protected function changeText(_arg1:GenericPopupEvent):void{
            this.m_cardHolder.removeAll();
            var _local2:AssetPane = ASwingHelper.makeMultilineCapsText(this.m_newMessage, 342, EmbeddedArt.TITLE_FONT, TextFormatAlign.CENTER, 14, EmbeddedArt.whiteTextColor);
            this.m_cardHolder.append(_local2);
            dispatchEvent(new Event(MakerPanel.PREPARE, true));
            StatsManager.count(StatsCounterType.CARDMAKER, StatsKingdomType.VDAY_2011, StatsPhylumType.CARDMAKER, "textchange", ((_arg1.button)==0) ? "close" : "ok");
        }
        protected function onNameDialogChange(_arg1:Event):void{
            var _local2:TextField = (_arg1.target as TextField);
            if (_local2){
                this.m_newMessage = _local2.text;
            };
        }

    }
}//package Display.ValentineUI 
